package com.javabi.htmlbuilder.css.declaration;

import com.javabi.htmlbuilder.HTMLColor;
import com.javabi.htmlbuilder.css.CSSBuilder;
import com.javabi.htmlbuilder.css.CSSDeclaration;
import com.javabi.htmlbuilder.css.CSSPropertyName;

/**
 * A CSS Color.
 */
public class CSSColor extends HTMLColor implements CSSDeclaration {

	/** The name. */
	private final CSSPropertyName name;

	/**
	 * Creates a new color.
	 * @param name the property name.
	 * @param color the color.
	 */
	public CSSColor(CSSPropertyName name, HTMLColor color) {
		super(color);
		if (name == null) {
			throw new NullPointerException();
		}
		this.name = name;
	}

	/**
	 * Returns the CSS property name.
	 * @return the CSS property name.
	 */
	public CSSPropertyName getPropertyName() {
		return name;
	}

	/**
	 * Append this to the given css builder.
	 * @param css the css builder.
	 * @return the css builder.
	 */
	public CSSBuilder appendTo(CSSBuilder css) {
		css.property(getPropertyName());
		css.color(this);
		return css;
	}
}
